package com.lc.qianrenshiye.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/12/14.
 */
@HttpInlet(Conn.STORE_BENEFIT)
public class VipBenefitGet extends BaseAsyGet<VipBenefitGet.VipEntity> {

    public String sid;

    public VipBenefitGet(AsyCallBack<VipEntity> asyCallBack) {
        super(asyCallBack);
    }

    @Override
    protected VipEntity parser(JSONObject object) throws Exception {

        TOAST = object.optString("message");

        if (object.optInt("code") == 200) {

            JSONObject infoObject = object.optJSONObject("data");

            VipEntity vipEntity = new VipEntity();

            vipEntity.level = infoObject.optString("level");
            vipEntity.integral = infoObject.optString("integral");
            vipEntity.need = infoObject.optString("need");

            JSONObject contentObject = infoObject.optJSONObject("list");

            vipEntity.name = contentObject.optString("name");

            vipEntity.contentList.add(contentObject.optString("thumb1"));
            vipEntity.contentList.add(contentObject.optString("thumb2"));
            vipEntity.contentList.add(contentObject.optString("thumb3"));

            return vipEntity;

        }


        return null;
    }

    public static class VipEntity {

        public String level, integral, need, name;

        public List<String> contentList = new ArrayList<>();

    }

}
